app.controller('indexCtrl', ['$scope', '$http', '$timeout',
  function($scope, $http, $timeout) {
    $scope.countObj = {};
    $timeout(function() {
      $http.post('/api/articles/readcount', { idArray: $scope.idArray })
        .success(function(res) {
          angular.forEach(res.data, function(value, key) {
            $scope.countObj[value.id] = value.readCount;
          });
        });
    }, 100);

    $scope.getReadCount = function(id) {
      return $scope.countObj[id] || 0;
    }
  }
]);
